package com.googlecode.gwtbb.client.shared.util;

import com.googlecode.gwtbb.client.shared.entity.properties.GetName;

import java.util.Comparator;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Jun 28, 2008
 */
public class ByName implements Comparator<GetName> {
	private static ByName instance = new ByName();

	public static boolean equals(GetName o1, GetName o2) {
		if (o1 == null)
			return o2 == null;
		return o2 != null && ObjectUtils0.nullSafeEquals(o1.getName(), o2.getName());
	}

	public static ByName instance() {
		return instance;
	}

	public int compare(GetName o1, GetName o2) {
		if (o1 == null)
			return o2 == null ? 0 : 1;
		return o2 == null ? -1 : ObjectUtils0.nullSafeCompareTo(o1.getName(), o2.getName());
	}
}